<%--
  Created by IntelliJ IDEA.
  User: zhaohongai
  Date: 2021/5/17
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/public/header/permissionCommon.jspf" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>设备档案</title>
    <c:set var="path" value="${pageContext.request.contextPath}" scope="page"/>
    <style type="text/css">
        .layui-table-tips-main{display:none}
        .layui-table-tips-c{display:none}
        .layui-table-grid-down {display: none;}
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <!-- 头部和左侧导航-->
    <div id="header"></div>
    <%--<!--右侧主体区域-->--%>
    <div class="layui-body" >
        <div class="layui-tab layui-tab-brief" lay-filter="SignList">
            <ul class="layui-tab-title">
                <li class="layui-this">设备档案</li>
            </ul>
            <div class="layui-tab-content">
                <%-----------护工设备信息展示-----------%>
                <!--
                <div id="HgDeviceInfoShow" class="layui-tab-item">
                    <%-----------搜索 & 添加 功能-----------%>
                    <div class="SearchLoadDevice" style="font-size: small">
                        <%------------搜索功能---------------%>
                        设备ID：
                        <div class="layui-inline">
                            <input class="layui-input" name="device_hg" id="device_hg" autocomplete="off" style="height: 30px;width:100px;margin-right: 10px">
                        </div>
                        状态：
                        <div class="layui-input-inline layui-form" style="width: 150px">
                            <select name="statusSearch_hg" id="statusSearch_hg" lay-filter="statusSearch_hg" class="select">
                                <option value="">全部</option>
                                <option value="0">已使用</option>
                                <option value="-1">未使用</option>
                            </select>
                        </div>
                        <div class="layui-inline">
                            <button class="searchBtn" data-type="reload1" style="margin-left:10px;height:30px;width:85px;background-color: #009688;color: white;border: none;border-radius: 5px">
                                <i class="layui-icon layui-icon-search"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center;margin-top: -6px;margin-left: 5px;margin-right: 5px">搜 索</div>
                            </button>
                        </div>
                        <%-------------添加护工设备-------------%>
                        <div class="layui-inline" style="float: right">
                            <button class="layui-btn layui-btn-sm" id="addHgDevice" name="addHgDevice"  style="width: 120px;margin-top:5px;float: right;border-radius: 5px;margin-left: 5px">
                                <i class="layui-icon layui-icon-add-1"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center">添加护工设备</div>
                            </button>
                        </div>
                    </div>
                    <%----------- 信息表格 显示------------%>
                    <table class="layui-hide" id="hgDeviceInfoList" lay-filter="deviceHg" ></table>
                </div>
                -->
                <div id="LrDeviceInfoShow" class="layui-tab-item layui-show">
                    <%-----------搜索 & 添加 功能-----------%>
                    <div class="SearchLoadDevice" style="font-size: small">
                        <%------------搜索功能---------------%>
                        设备ID：
                        <div class="layui-inline">
                            <input class="layui-input" name="device_lr" id="device_lr" autocomplete="off" style="height: 30px;width:100px;margin-right: 10px">
                        </div>
                        状态：
                        <div class="layui-input-inline layui-form" style="width: 150px">
                            <select name="statusSearch_lr" id="statusSearch_lr" lay-filter="statusSearch_lr" class="select">
                                <option value="">全部</option>
                                <option value="0">已使用</option>
                                <option value="-1">未使用</option>
                            </select>
                        </div>
                        <div class="layui-inline">
                             <button class="searchBtn" data-type="reload2" style="margin-left:10px;height:30px;width:85px;background-color: #009688;color: white;border: none;border-radius: 5px">
                                 <i class="layui-icon layui-icon-search"></i>
                                 <div class="layui-inline" style="font-size: small;text-align:center;margin-top: -6px;margin-left: 5px;margin-right: 5px">搜 索</div>
                             </button>
                        </div>
                        <div class="layui-inline" style="float: right">
                            <button class="layui-btn layui-btn-sm" id="addLrDevice" name="addLrDevice" style="width: 120px;margin-top:5px;float: right;border-radius: 5px;margin-left: 5px">
                                <i class="layui-icon layui-icon-add-1"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center">添加老人设备</div>
                            </button>
                        </div>
                    </div>
                        <%----------- 信息表格 显示------------%>
                        <table class="layui-hide" id="lrDeviceInfoList" lay-filter="deviceLr" ></table>
                </div>
            </div>
        </div>
    </div>
    <!--底部-->
    <div id="footer"></div>
    <script src="${webPath}/js/permission/auth/permList.js"></script>
    <script>
        $("#header").load("${webPath}/publicPages/permission/fragments/header.jsp");
        $("#footer").load("${webPath}/publicPages/permission/fragments/footer.jsp");
    </script>
    <script type="text/javascript" src="${webPath}/js/Sign/DeviceFileList.js"></script>
    <%-------------查看编辑删除框--------------%>
    <%--护工设备页面的编辑框--%>
    <script type="text/html" id="Check_Edit_Del_Hg">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <%--老人设备页面的编辑框--%>
    <script type="text/html" id="Check_Edit_Del_Lr">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script type="text/javascript" src="${webPath}/js/utils.js"></script>

    <%--查看护工设备详细信息--%>
    <div class="hgDeviceDetail" id="hgDeviceDetail" style="display: none">
        <form class="layui-form layui-form-pane" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label" >护工设备ID</label>
                    <div class="layui-input-block">
                        <input type="text" name="device_hg" value={device_hg} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">所属机构</label>
                    <div class="layui-input-block">
                        <input type="text" name="organization" value={organization} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="createTime" readonly="readonly" value={createTime}  class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">更新时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="updateTime" readonly="readonly" value={updateTime} step="1" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">设备状态</label>
                    <div class="layui-input-block">
                        <input type="text" name="state" value={state} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">备注信息</label>
                    <div class="layui-input-block">
                        <input type="text" name="note" value={note} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
        </form>
    </div>

    <%--查看老人设备详细信息--%>
    <div class="lrDeviceDetail" id="lrDeviceDetail" style="display: none">
        <form class="layui-form layui-form-pane" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label" >老人设备ID</label>
                    <div class="layui-input-block">
                        <input type="text" name="device_lr" value={device_lr} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">所属机构</label>
                    <div class="layui-input-block">
                        <input type="text" name="organization" value={organization} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="createTime" readonly="readonly" value={createTime}  class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">更新时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="updateTime" readonly="readonly" value={updateTime} step="1" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">设备状态</label>
                    <div class="layui-input-block">
                        <input type="text" name="state" value={state} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">备注信息</label>
                    <div class="layui-input-block">
                        <input type="text" name="note" value={note} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
        </form>
    </div>

    <%--编辑护工设备信息--%>
    <div class="editHgDevice" id="hgDeviceEdit" style="display: none;">
        <form class="layui-form layui-form-pane" id="HgDeviceForm" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;" action="">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>护工设备</label>
                    <div class="layui-input-block">
                        <input type="text" name="device_hg" value={device_hg} lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>所属机构</label>
                    <div class="layui-input-block">
                        <input type="text" name="organization" value={organization} lay-verify="required" class="layui-input" readonly>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="createTime" class="layui-input" value={createTime} step="1" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">更新时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="updateTime" class="layui-input" value={updateTime} step="1" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>备注信息</label>
                    <div class="layui-input-block">
                        <input type="text" name="note" value={note} lay-verify="required" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="display: none">
                <label class="layui-form-label">序号</label>
                <div class="layui-input-block">
                    <input type="text" name="id" value={id} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item" align="center" style="margin-top: 20px;margin-bottom: 20px">
                <button type="submit" class="layui-btn" lay-submit="" id="handinHg" lay-filter="handinEditHg" style="margin-right: 20px">
                    <div style="font-weight: bold;font-size: medium">立 即 提 交</div>
                </button>
                <button class="layui-btn layui-btn-primary" style="width:100px" type="button">
                    <div style="font-weight: bold;font-size: medium" onclick="javascript:history.go(-1)">取&nbsp&nbsp&nbsp&nbsp消</div>
                </button>
            </div>
        </form>
    </div>
    <script>
        layui.use('form', function(){
            var form = layui.form;
            form.on('submit(handinEditHg)', function(data){
                console.log("[开始提交~]");
                console.log(data.field);
                $.ajax({
                    url:'/DeviceHg/updateHgDevice',
                    method:'POST',
                    data:data.field,
                    dataType:'JSON',
                    success:function(res){
                        console.log("[res:]"+res);
                        if(res==0){
                            console.log("[成功提交~]"+data.field);
                            layer.msg("提交成功!",{icon: 1, time: 1500},function(){location.reload();}); //提交成功后刷新页面
                            // alert("提交成功");
                        }else{
                            layer.msg("请确保输入正确!",{ icon: 5,anim: 6,offset: "auto"});
                        }
                    },
                    error:function (data) {
                        console.log("[提交失败~]",data);
                    }
                });
                return false;
            })
        })
    </script>

    <%--编辑老人设备信息--%>
    <div class="editLrDevice" id="lrDeviceEdit" style="display: none;">
        <form class="layui-form layui-form-pane" id="LrDeviceForm" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;" action="">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>老人设备</label>
                    <div class="layui-input-block">
                        <input type="text" name="device_lr" value={device_lr} lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>所属机构</label>
                    <div class="layui-input-block">
                        <input type="text" name="organization" value={organization} lay-verify="required" class="layui-input" readonly>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="createTime" class="layui-input" value={createTime} step="1" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">更新时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="updateTime" class="layui-input" value={updateTime} step="1" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>备注信息</label>
                    <div class="layui-input-block">
                        <input type="text" name="note" value={note} lay-verify="required" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item" style="display: none">
                <label class="layui-form-label">序号</label>
                <div class="layui-input-block">
                    <input type="text" name="id" value={id} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item" align="center" style="margin-top: 20px;margin-bottom: 20px">
                <button type="submit" class="layui-btn" lay-submit="" id="handinLr" lay-filter="handinEditLr" style="margin-right: 20px">
                    <div style="font-weight: bold;font-size: medium">立 即 提 交</div>
                </button>
                <button class="layui-btn layui-btn-primary" style="width:100px" type="button">
                    <div style="font-weight: bold;font-size: medium" onclick="javascript:history.go(-1)">取&nbsp&nbsp&nbsp&nbsp消</div>
                </button>
            </div>
        </form>
    </div>
    <script>
        layui.use('form', function(){
            var form = layui.form;
            form.on('submit(handinEditLr)', function(data){
                console.log("[开始提交~]");
                console.log(data.field);
                $.ajax({
                    url:'/DeviceLr/updateLrDevice',
                    method:'POST',
                    data:data.field,
                    dataType:'JSON',
                    success:function(res){
                        console.log("[res:]"+res);
                        if(res==0){
                            console.log("[成功提交~]"+data.field);
                            layer.msg("提交成功!",{icon: 1, time: 1500},function(){location.reload();}); //提交成功后刷新页面
                            // alert("提交成功");
                        }else{
                            layer.msg("请确保输入正确!",{ icon: 5,anim: 6,offset: "auto"});
                        }
                    },
                    error:function (data) {
                        console.log("[提交失败~]",data);
                    }
                });
                return false;
            })
        })
    </script>

    <%--添加护工设备--%>
    <div class="addHgDevice" id="addHgDeviceWindow" style="display: none;">
        <form class="layui-form layui-form-pane" id="addHgDeviceForm" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;" action="">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label">设备ID</label>
                    <div class="layui-input-inline">
                        <input type="text" name="device_hg" lay-verify="required" placeholder="请输入设备ID" class="layui-input" value="">
                    </div>
                </div>
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label">设备状态</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="state" value="0" title="已使用">
                        <input type="radio" name="state" value="-1" title="未使用" checked>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-inline">
                        <input type="text" name="note" lay-verify="required" placeholder="请输入备注信息" class="layui-input" value="">
                    </div>
                </div>
            </div>
            <div class="layui-form-item" align="center" style="margin-top: 20px;margin-bottom: 20px">
                <button type="submit" class="layui-btn" lay-submit="" id="handinAddHgDevice" lay-filter="handinAddHg" style="margin-right: 20px">
                    <div style="font-weight: bold;font-size: medium">立 即 提 交</div>
                </button>
                <button class="layui-btn layui-btn-primary" style="width:100px" type="button">
                    <div style="font-weight: bold;font-size: medium" onclick="javascript:history.go(-1)">取&nbsp&nbsp&nbsp&nbsp消</div>
                </button>
            </div>
        </form>
    </div>
    <script type="text/javascript">
        $("#addHgDevice").on("click", function(){
            var index = layer.open({
                type: 1,  //可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                title: ['添加护工设备', 'font-size:18px;'],
                area: ['700px',"400px"],
                content: $('#addHgDeviceWindow')
            });
        })
    </script>
    <script>
        layui.use('form', function(){
            var form = layui.form;
            form.on('submit(handinAddHg)', function(data){
                console.log("[开始提交~]");
                console.log("[date:]",data);
                $.ajax({
                    url:'/DeviceHg/addHgDevice',
                    method:'POST',
                    data:{
                        device_hg: data.field.device_hg,
                        note: data.field.note,
                        state: data.field.state
                    },
                    dataType:'JSON',
                    success:function(res){
                        console.log("[res:]"+res);
                        if(res==0){
                            console.log("[成功提交~]"+data.field);
                            layer.msg("提交成功!",{icon: 1, time: 1500},function(){location.reload();}); //提交成功后刷新页面
                            // alert("提交成功");
                        }else{
                            layer.msg("请确保输入正确!",{ icon: 5,anim: 6,offset: "auto"});
                        }
                    },
                    error:function (data) {
                        console.log("[提交失败~]",data);
                    }
                });
                return false;
            })
        })
    </script>

    <%--添加老人设备--%>
    <div class="addLrDevice" id="addLrDeviceWindow" style="display: none;">
        <form class="layui-form layui-form-pane" id="addLrDeviceForm" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;" action="">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label">设备ID</label>
                    <div class="layui-input-inline">
                        <input type="text" name="device_lr" lay-verify="required" placeholder="请输入设备ID" class="layui-input" value="">
                    </div>
                </div>
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label">设备状态</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="state" value="0" title="已使用">
                        <input type="radio" name="state" value="-1" title="未使用" checked>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-inline">
                        <input type="text" name="note" lay-verify="required" placeholder="请输入备注信息" class="layui-input" value="">
                    </div>
                </div>
            </div>
            <div class="layui-form-item" align="center" style="margin-top: 20px;margin-bottom: 20px">
                <button type="submit" class="layui-btn" lay-submit="" id="handinAddLrDevice" lay-filter="handinAddLr" style="margin-right: 20px">
                    <div style="font-weight: bold;font-size: medium">立 即 提 交</div>
                </button>
                <button class="layui-btn layui-btn-primary" style="width:100px" type="button">
                    <div style="font-weight: bold;font-size: medium" onclick="javascript:history.go(-1)">取&nbsp&nbsp&nbsp&nbsp消</div>
                </button>
            </div>
        </form>
    </div>
    <script type="text/javascript">
        $("#addLrDevice").on("click", function(){
            var index = layer.open({
                type: 1,  //可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加载层）4（tips层）
                title: ['添加老人设备', 'font-size:18px;'],
                area: ['700px',"400px"],
                content: $('#addLrDeviceWindow')
            });
        })
    </script>
    <script>
        layui.use('form', function(){
            var form = layui.form;
            form.on('submit(handinAddLr)', function(data){
                console.log("[开始提交~]");
                console.log("[date:]",data);
                $.ajax({
                    url:'/DeviceLr/addLrDevice',
                    method:'POST',
                    data:{
                        device_lr: data.field.device_lr,
                        note: data.field.note,
                        state: data.field.state
                    },
                    dataType:'JSON',
                    success:function(res){
                        console.log("[res:]"+res);
                        if(res==0){
                            console.log("[成功提交~]"+data.field);
                            layer.msg("提交成功!",{icon: 1, time: 1500},function(){location.reload();}); //提交成功后刷新页面
                            // alert("提交成功");
                        }else{
                            layer.msg("请确保输入正确!",{ icon: 5,anim: 6,offset: "auto"});
                        }
                    },
                    error:function (data) {
                        console.log("[提交失败~]",data);
                    }
                });
                return false;
            })
        })
    </script>

</div>
</body>
</html>
